<?php
namespace App\Common\Lib\Com\RabbitMQ;

use App\Common as com;
use App\Common\Lib\Com\RabbitMQ\_Channel as name_Channel;
use App\Common\Lib\Com\RabbitMQ as nameRabbitMQ;
use PhpAmqpLib\Channel\AMQPChannel;

/**
 * @property nameRabbitMQ\DataStore $dataStore
 */
class _Channel extends com\Cla\ClaBase\CommonOfId\Client {

	private AMQPChannel $channel;

	/**
	 * _Channel constructor.
	 * @param com\Cla\ClaBase\DataStore $dataStore
	 * @throws
	 */
	public function __construct( com\Cla\ClaBase\DataStore $dataStore ) {
		parent::__construct( $dataStore );
		//
		$a = $this->dataStore->main->getAMQPConnection();
		$this->channel = $a->getChannel();
	}

	public function __destruct(  ) {
		// d('__destruct _Channel');
		//
		parent::__destruct();
	}


	/**
	 * @return AMQPChannel
	 */
	public function getChannel(  ):AMQPChannel {
		return $this->channel;
	}

	/**
	 * @param string $exchangeName
	 * @return _Channel\_Exchange
	 * @throws
	 */
	public function newExchange( string $exchangeName ):name_Channel\_Exchange {
		return name_Channel\_Exchange::make( $this->dataStore, $this->getChannel(), $exchangeName );
	}

	/**
	 * @param string $queueName
	 * @return _Channel\_Queue
	 * @throws
	 */
	public function newQueue( string $queueName ):name_Channel\_Queue {
		return name_Channel\_Queue::make( $this->dataStore, $this->getChannel(), $queueName );
	}
	
}
